package com.example.web;

import com.example.pojo.Student;
import com.example.service.StudentService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet(name = "UpdatesServlet", value = "/UpdatesServlet")
public class UpdatesServlet extends HttpServlet {

    private StudentService service = new StudentService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {


        String id = request.getParameter("id");
        String name = request.getParameter("name");
        String city = request.getParameter("city");
        String age = request.getParameter("age");

        Student student= new Student();

        student.setId(Integer.parseInt(id));
        student.setName(name);
        student.setAge(age);
        student.setCity(city);

         service.Update(student);

         request.getRequestDispatcher("/SelectAllServlet").forward(request,response);

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
